package org.zhaolei.config;

import com.alipay.api.AlipayClient;
import com.alipay.api.DefaultAlipayClient;
import lombok.Data;
import org.springframework.context.annotation.Configuration;

@Configuration
@Data
public class AlipayConfig {

    public static final String PAY_GATEWAY = "https://openapi.alipaydev.com/gateway.do";

    /**
     * 支付宝 APPID
     */
    public static final String APPID = "2021000147693395";

    /**
     * 应用私钥
     */
    public static final String APP_PRI_KEY = "MIIEpAIBAAKCAQEAt2vuG0rTBh44uss7DrXpK46kRZHyqqZdKY1CU7S7hzTGwKDRus7boP/RnFKZX6Hc2yfq0zKvkPOu53jzsgPqajD3WAhqQqp6F7hIOLkTdNlIwHYg0eLpOrNJyLEtQn3vkT0j6tPBIkUTSJXL+COglO2/kbM1QGrUQj00d+AarC5nUDcWl43axZzgfyr4AUnf9ALZeGkNgTqebzJ9t5dOQoyNLA8b5Rhz+CEWciMWM8V/kq7ez/aIjFf+Aob4qEtB5Ts8Vl/r9TyKMsT/nxuuCl1kwgT4ts6Gj4Gn8rdLwzmD0DzMwjDSF8dIcgGOg4anZAVxQirbsRFspFDKMgulUQIDAQABAoIBAG67hPMLGKZ4Uu4sInmYpO1mOE6xgchdBboZZeXjEbKs1PSD4joCGgu3hUb3gsp+QIQ6NAUuy1kaFFR/67djr8hOKXUHF4eJvc3GHivIZ9uaNdajOisb7yvWA0wYeOLrLOw616SuOpEWR8qqmXSmNQlO0u4R+msaU2xt4Ngh/lhFYQrFsqF312Cqeqr205roqaXoDNYRDvgQ48zQbImAdTn1NLp2KSl3ZMMmIclUmaT/6Pb59/B8OF9zDSzbsf+PnRsXmZKDSaiKg6OLQ+dobOgN5D7roviIlxeWtZ16J3NimUehxhzAgUAqaSPozyzgNU1h68CPhZRYDXiQ4GbCWRUCgYEA6cVGMcsKZ3j7MjQ7YgtAk0NcIv4led/0R5IE84mrLCPkq7VABdhY4+Da9oYM4gUlOMdRmRgpW4D27QxvDcMQ+9q78tFc5U5jan5av2SKFJ3p9sVAkknU4vaKf/NmsUokbPaGKHpIrh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0fH47YyxOeoo8cJr1TBh44uss7DrXpK46kRZHyqqZdKY1CU7S7hoGBAN9X0SVfqkq2LdwGBf50kOwcI6CigAVFLTImJE7C2ma3F800MqE/0Bgpshh06e1nAGTbpH5El2ukY1Gt+qPPNYDxFIK9x2nbwu5NPMLIbwD6cdGrFv5qsg02/0bIuihGYnnVHkmN+dg5yR592+2t5soo18BlMB0vAgf6+4jawlcN";
//应用公钥：MIIBIjANBgkqhkiG9w0BAQEFAAOCAQ8AMIIBCgKCAQEAt2vuG0rTBh44uss7DrXpK46kRZHyqqZdKY1CU7S7hzTGwKDRus7boP/RnFKZX6Hc2yfq0zKvkPOu53jzsgPqajD3WAhqQqp6F7hIOLkTdNlIwHYg0eLpOrNJyLEtQn3vkT0j6tPBIkUTSJXL+COglO2/kbM1QGrUQj00d+AarC5nUDcWl43axZzgfyr4AUnf9ALZeGkNgTqebzJ9t5dOQoyNLA8b5Rhz+CEWciMWM8V/kq7ez/aIjFf+Aob4qEtB5Ts8Vl/r9TyKMsT/nxuuCl1kwgT4ts6Gj4Gn8rdLwzmD0DzMwjDSF8dIcgGOg4anZAVxQirbsRFspFDKMgulUQIDAQAB

    /**
     * 支付宝公钥
     */
    public static final String ALIPAY_PUB_KEY = "MIIBIjANBgkqhkiG9w0BAQEFAAOCAQ8AMIIBCgKCAQEAgACle2A/8carfwVlSCjJ1t1qcG1jmjPjIsl4ihfDKtKDumDAVRsPrPc7UzpceQYmKv7ZgFBcC4uNejNEGcD5//DvnkNtiqra/hGRaMCxsQZHwwK3ioESlV0SrvRJ+SzHrjT8a+QKSa67fD/rOHcDlJyotk0kz5dHm02TjtzH+2ZqFt7R1ONiMp+iMKxVnLxcEPILIPmlN2tC1116u4jR9po/gWCAUrRNVx+cyGnBwlkTUr/V6kK2C5+x2Og3YVqn8b0aa8MKLz3XJEPzWyq+vMPpugk5uI9I3YvbGsLYCUvTBh44uss7DrXpK46kRZHyqqZdKY1CU7S7hvceLt9OVQIDAQAB";

    /**
     * 签名类型
     */
    public static final  String SIGN_TYPE="RSA2";

    /**
     * 返回格式
     */
    public static final String FORMAT = "json";

    /**
     * 字符编码
     */
    public static final  String CHARSET="UTF-8";


    public AlipayConfig(){

    }

    private volatile static AlipayClient instance = null;

    /**
     * 单例模式获取, 双重锁校验
     * @return
     */
    public static AlipayClient getInstance(){

        if(instance==null){
            synchronized (AlipayConfig.class){
                if(instance == null){
                    instance = new DefaultAlipayClient(PAY_GATEWAY,APPID,APP_PRI_KEY,FORMAT,CHARSET,ALIPAY_PUB_KEY,SIGN_TYPE);
                }
            }
        }
        return instance;
    }
}
